package com.second.app.thread.线程基础.day03.twoobjecttwolock;

/**
 * @Author GYZ
 * @Date 2023/11/21
 * <pre>
 *
 * </pre>
 */
public class HasSelfPrivateNum {

    int num = 0;
    public synchronized void addI(String userName) {
        try {
            if (userName.equals("a")) {
                num=100;
                System.out.println("a set over");
                Thread.sleep(2000);
            } else {
                num = 200;
                System.out.println("b set over");
            }
            System.out.println(userName + " num=" + num);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
